package cn.gov.cus.rmftquartz.thread;

import com.google.common.base.Stopwatch;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * 有返回值的线程类demo。类名随便起。这里面还有谷歌计时器的demo。
 * @author wxming.
 * @date 2018/1/30.
 */
public class CallableThread implements Callable<List<String>> {
    private String canshu1;
    private String canshu2;

    public CallableThread(String canshu1, String canshu2) {
        this.canshu1 = canshu1;
        this.canshu2 = canshu2;
    }

    @Override
    public List<String> call() throws Exception {
        try{
            List<String> listResultBean = new ArrayList<>();

            //谷歌计时器。创建计时器并启动。
            Stopwatch stopwatch = Stopwatch.createStarted();//guava-22.0.jar中com.google.common.base.Stopwatch.class。
            long nowTime=0;

            //线程睡一下
            Thread.sleep(1000);

            //获取当前计算出的时间差（此处是秒）。
            nowTime=stopwatch.elapsed(TimeUnit.SECONDS);
            //停止计时器。
            stopwatch.stop();

            return listResultBean;
        }catch (Exception e){
            return null;
        }

    }
}
